//
//  YXYWallLikeLowerCollectionViewCell.m
//  Topit
//
//  Created by dllo on 15/12/9.
//  Copyright © 2015年 YXY. All rights reserved.
//

#import "YXYWallLikeLowerCollectionViewCell.h"

@implementation YXYWallLikeLowerCollectionViewCell

- (void)dealloc {
    [_label release];
    [_array release];
    [_myView release];
    [_myImageView release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.myImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
        [self addSubview:_myImageView];
        [_myImageView release];
        
        self.myView = [[UIView alloc] initWithFrame:CGRectZero];
        _myView.backgroundColor = [UIColor blackColor];
        _myView.alpha = 0.6;
        [self addSubview:_myView];
        [_myView release];

        self.label = [[UILabel alloc] initWithFrame:CGRectZero];
        _label.textAlignment = 1;
        _label.textColor = [UIColor whiteColor];
        _label.font = [UIFont systemFontOfSize:10];
        [_myView addSubview:_label];
        [_label release];
    }
    return self;
}

- (void)setWallItemModel:(YXYWallItemModel *)wallItemModel {
    if (_wallItemModel != wallItemModel) {
        [_wallItemModel release];
        _wallItemModel = [wallItemModel retain];
    }
    [_myImageView sd_setImageWithURL:[NSURL URLWithString:wallItemModel.icon[@"url"]]];
    _label.text = wallItemModel.name;
}

-(void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    _myImageView.frame = CGRectMake(1, 10, self.width - 10, self.height - 2);
    _label.frame = CGRectMake(-1, 0, self.width, self.height);
    _myView.frame = CGRectMake(_myImageView.origin.x, _myImageView.origin.y, _myImageView.width, _myImageView.height);
}
@end
